from django.db import models
from .base import BaseModel

class CharacterTemplate(BaseModel):
    """角色模板模型"""
    name = models.CharField(max_length=50, verbose_name='模板名称')
    description = models.TextField(blank=True, verbose_name='模板描述')
    
    # 模板创建者
    creator = models.ForeignKey(
        'accounts.User',
        on_delete=models.CASCADE,
        related_name='created_templates',
        verbose_name='创建者'
    )
    
    # 模板权限
    is_public = models.BooleanField(default=False, verbose_name='是否公开')
    allowed_users = models.ManyToManyField(
        'accounts.User',
        blank=True,
        related_name='accessible_templates',
        verbose_name='允许使用的用户'
    )
    
    # 模板数据
    template_data = models.JSONField(verbose_name='模板数据')
    
    # 模板类型
    TEMPLATE_TYPES = [
        ('npc', 'NPC'),
        ('player', '玩家角色'),
        ('monster', '怪物'),
        ('other', '其他'),
    ]
    template_type = models.CharField(
        max_length=20,
        choices=TEMPLATE_TYPES,
        default='other',
        verbose_name='模板类型'
    )
    
    # 模板标签
    tags = models.CharField(max_length=200, blank=True, verbose_name='标签')
    
    class Meta:
        verbose_name = '角色模板'
        verbose_name_plural = '角色模板'
        ordering = ['-created_at']
